<?php


namespace app\api\controller\v10;


use app\api\controller\v2\Auth;
use app\common\model\ZhunleUserAccount as UserAccountModel;
use app\common\model\ZhunleUserBindAlipay;

class UserAccount extends Auth
{
    public function getAccountInfo()
    {
        $uid = $this->user['id'];
        // 获取账户信息
        $accountInfo = (new UserAccountModel())->getAccountInfoAndCreate($uid);

        $msg = $accountInfo['status'] == 2 ? '账户已冻结' : '';
        //获取支付宝绑定信息
        $aliNumberInfo = (new ZhunleUserBindAlipay())->getAliNumberInfo($uid);

        $result = [
            'balance' => (string)$accountInfo['balance'],
            'alipay_account' => $aliNumberInfo['alipay_account'],
            'status' => $accountInfo['status'],
            'msg' => $msg
        ];

        return show(config('code.success'), '请求成功', $result);
    }

}
